package com.lyb.hrm.fallback;
import com.lyb.hrm.feignclients.FastdfsFeignClient;
import com.lyb.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class FastdfsFeignClientFallbackFactory implements FallbackFactory<FastdfsFeignClient> {
    @Override
    public FastdfsFeignClient create(Throwable throwable) {
        return new FastdfsFeignClient() {

            @Override
            public byte[] download(String path) {
                throwable.printStackTrace();
                return null;
            }

            @Override
            public AjaxResult uploadBytes(byte[] file, String extName) {
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("文件上传失败");
            }
        };
    }
}
